<?php
if(!defined('BLOG'))exit('不作死就不会死');
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/1/7
 * Time: 14:35
 */
base::load_class('mysql');

/**
 * Class model
 */
class model{
    public $table;
    public $prefix;
    public $config;
    public $db;
    public $seting;

    /**
     *
     */
    public function __construct(){
        if(!isset($this->seting)){
            $this->config = $this->config['default'];
        }
        $this->config = $this->config[$this->seting];
        $this->prefix = $this->config['db_prefix'];
        $this->table = $this->prefix.$this->table;
        $this->db = new mysql($this->config);
    }

    /**
     * @param string $data
     * @param string $where
     * @param string $order
     * @param string $limit
     * @param string $group
     * @return array|bool|mysqli_result
     */
    public function select($data = '*',$where='',$order='',$limit='',$group=''){
        return $this->db->select($data,$this->table,$where,$order,$limit,$group);
    }

    /**
     * @param $where
     * @param $data
     * @return array|bool|mysqli_result
     */
    public function update($where,$data){
        return $this->db->update($where,$data,$this->table);
    }

    /**
     * @param $data
     * @return array|bool|mysqli_result
     */
    public function insert($data){
        return $this->db->insert($data,$this->table);
    }

    /**
     * @param $where
     * @return array|bool|mysqli_result
     */
    public function delete($where){
       return $this->db->delete($where,$this->table);
    }
    public function get_one($data,$where){
        return $this->db->get_one($data,$this->table,$where);
    }
    public function insertid(){
        return $this->db->insertid();
    }
}